﻿using System.Drawing;

namespace MathService.Functions.Plotter.GraphComponents
{
    class Cursor : IGraphElement
    {
        private readonly Channel channel;

        public Cursor(Channel channel) { this.channel = channel; }

        public Rectangle GraphArea { get; set; }

        #region IGraphElement Members

        public void Draw(Graphics graphics)
        {
            int num = GraphArea.Height/2;
            float num2 = channel.MaximumValue - channel.MinimumValue;
            var num3 = (int)(((GraphArea.Height)/num2)*channel.CursorOffset);
            var point = new Point
                            {
                                        X = GraphArea.Left,
                                        Y = (GraphArea.Bottom - num) + num3
                            };
            var point2 = new Point(GraphArea.Right, point.Y);
            graphics.DrawLine(new Pen(channel.ChannelColor), point, point2);
        }

        #endregion
    }
}
